<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
function jieguo_table(){
	$('#TrainingResulttable').datagrid({    
		 url:'TrainingResulttables', //数据源地址
	   columns:[[    
	       {field:'empid',fixed:false,width:213,title:'员工编号',hidden:true,align:'center'},  
	       {field:'rusid',fixed:false,width:213,title:'课程编号',hidden:true,align:'center'},  
	       {field:'retrem',fixed:false,width:213,title:'结果状态',hidden:true,align:'center'},
	       {field:'retid',fixed:false,width:213,title:'结果id',hidden:true,align:'center'},
	       {field:'empname',fixed:false,width:213,title:'员工姓名',align:'center'},    
	       {field:'planname',fixed:false,width:213,title:'培训项目',align:'center'},
	       {field:'rusname',fixed:false,width:213,title:'培训课程',align:'center'},
	       {field:'clsname',fixed:false,width:213,title:'证书',align:'center',
	    	   formatter : function(value,row,index) {
			       	if(row['retrem']==0||row['retrem']==-1){
			       		return "<span  onclick=''>未获得"+value+"</span>";
			       	}else if(row['retrem']==1){
			       		return "<span  onclick=''>已获得"+value+"</span>";
			       	}
			   	}    
	       } ,
	       {field:'trtsfens',fixed:false,width:213,title:'分数(75分通过)',align:'center'},
	       {field:'caozuo',fixed:false,width:213,title:'操作',align:'center',
	    	   formatter : function(value,row,index) {
			       	if(row['retrem']==0&&row['trtsfens']>=75){
			           $.ajax({
			       			type:"post",
			       			url:'rus_jieguo', //数据源地址
			       			data:{"retid":row["retid"]},
			       			success: function(datas){  
			       				jieguo_table();
			       			}
			       		})
			       	}else if(row['retrem']==0&&row['trtsfens']<=75){
			       		$.ajax({
			       			type:"post",
			       			url:'rus_butongguo', //数据源地址
			       			data:{"retid":row["retid"]},
			       			success: function(datas){  
			       				jieguo_table();
			       			}
			       		})
			       	}/* else{
			       		$.ajax({
			       			type:"post",
			       			url:'rus_butongguo', //数据源地址
			       			data:{"retid":row["retid"]},
			       			success: function(datas){  
			       				jieguo_table();
			       			}
			       		})
			       	} */
			       	if(row['retrem']==1){
			    		return "<span  onclick=''style='color:green;'>已通过</span>";
			    	}else if(row['retrem']==-1){
			    		return "<span  onclick=''style='color:red;'>未通过</span>";
			    	}
			   	}   
	       }
	       ]],
	   pagination:true,
	   pageNumber:1,
	   pageSize:5,
	   pageList:[5,10,15] 
	}); 
}
function jiluall(){
	$('#jilu_all').datagrid({    
 		url:'jilu_all', //数据源地
		 columns:[[    
		       {field:'empid',fixed:false,width:213,title:'员工编号',hidden:true,align:'center'},  
		       {field:'rusid',fixed:false,width:213,title:'课程编号',hidden:true,align:'center'},  
		       {field:'empname',fixed:false,width:213,title:'员工姓名',align:'center'},    
		       {field:'planname',fixed:false,width:213,title:'培训项目',align:'center'},
		       {field:'rusname',fixed:false,width:213,title:'培训课程',align:'center'},
		       {field:'plannind',fixed:false,width:213,title:'开始时间',align:'center',
		    	   formatter : function(value){
		        		var d = new Date(value);
		        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
		        		return times;
		        	}   
		       },
		       {field:'planmaxd',fixed:false,width:213,title:'结束时间',align:'center',
		    	   formatter : function(value){
		        		var d = new Date(value);
		        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
		        		return times;
		        	}     
		       },
		       {field:'plandd',fixed:false,width:213,title:'培训地点',align:'center'}
		       ]],
		   pagination:true,
		   pageNumber:1,
		   pageSize:5,
		   pageList:[5,10,15] 
	
	}); 
}
$(function(){
	jieguo_table();
	jiluall();
	  $('#ss').searchbox({
		 searcher : function (value, name) {
				    $.ajax({
		       			type:"post",
		       			url:'rus_rust_name', //数据源地址
		       			data:{"empname":value},
		       			success: function(datas){  
		       				if(value==""||datas<0){
		       					jiluall();
		       				}else if(datas>0){
		       				$('#jilu_all').datagrid({    
		       			 		url:'rus_rust_name_table', //数据源地
		       					 columns:[[    
		       					       {field:'empid',fixed:false,width:213,title:'员工编号',hidden:true,align:'center'},  
		       					       {field:'rusid',fixed:false,width:213,title:'课程编号',hidden:true,align:'center'},  
		       					       {field:'empname',fixed:false,width:213,title:'员工姓名',align:'center'},    
		       					       {field:'planname',fixed:false,width:213,title:'培训项目',align:'center'},
		       					       {field:'rusname',fixed:false,width:213,title:'培训课程',align:'center'},
		       					       {field:'plannind',fixed:false,width:213,title:'开始时间',align:'center',
		       					    	   formatter : function(value){
		       					        		var d = new Date(value);
		       					        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
		       					        		return times;
		       					        	}   
		       					       },
		       					       {field:'planmaxd',fixed:false,width:213,title:'结束时间',align:'center',
		       					    	   formatter : function(value){
		       					        		var d = new Date(value);
		       					        		var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
		       					        		return times;
		       					        	}     
		       					       },
		       					       {field:'plandd',fixed:false,width:213,title:'培训地点',align:'center'}
		       					       ]]
		       				  });
		       				}
		       			}
		       		}) 
				   
			   
		 }
		 
	 }) 
	 
	 //根据员工姓名查询结果yy_
 	  $('#yy_').searchbox({
		 searcher : function (value, name) {
				    $.ajax({
		       			type:"post",
		       			url:'TrainingResulttable_cha', //数据源地址
		       			data:{"empname":value},
		       			success: function(datas){  
		       				if(value==""||datas<0){
		       					jieguo_table();
		       				}else if(datas>0){
				       				$('#TrainingResulttable').datagrid({    
				       			 		url:'TrainingResulttable_name', //数据源地
				       			 	  columns:[[    
				       			       {field:'empid',fixed:false,width:213,title:'员工编号',hidden:true,align:'center'},  
				       			       {field:'rusid',fixed:false,width:213,title:'课程编号',hidden:true,align:'center'},  
				       			       {field:'retrem',fixed:false,width:213,title:'结果状态',hidden:true,align:'center'},
				       			       {field:'retid',fixed:false,width:213,title:'结果id',hidden:true,align:'center'},
				       			       {field:'empname',fixed:false,width:213,title:'员工姓名',align:'center'},    
				       			       {field:'planname',fixed:false,width:213,title:'培训项目',align:'center'},
				       			       {field:'rusname',fixed:false,width:213,title:'培训课程',align:'center'},
				       			       {field:'clsname',fixed:false,width:213,title:'证书',align:'center',
				       			    	   formatter : function(value,row,index) {
				       					       	if(row['retrem']==0||row['retrem']==-1){
				       					       		return "<span  onclick=''>未获得"+value+"</span>";
				       					       	}else if(row['retrem']==1){
				       					       		return "<span  onclick=''>已获得"+value+"</span>";
				       					       	}
				       					   	}    
				       			       } ,
				       			       {field:'trtsfens',fixed:false,width:213,title:'分数(75分通过)',align:'center'},
				       			       {field:'caozuo',fixed:false,width:213,title:'操作',align:'center',
				       			    	   formatter : function(value,row,index) {
				       					       	if(row['retrem']==0&&row['trtsfens']>=75){
				       					           $.ajax({
				       					       			type:"post",
				       					       			url:'rus_jieguo', //数据源地址
				       					       			data:{"retid":row["retid"]},
				       					       			success: function(datas){  
				       					       				jieguo_table();
				       					       			}
				       					       		})
				       					       	}else if(row['retrem']==0&&row['trtsfens']<=75){
				       					       		$.ajax({
				       					       			type:"post",
				       					       			url:'rus_butongguo', //数据源地址
				       					       			data:{"retid":row["retid"]},
				       					       			success: function(datas){  
				       					       				jieguo_table();
				       					       			}
				       					       		})
				       					       	}
				       					       	if(row['retrem']==1){
				       					    		return "<span  onclick=''style='color:green;'>已通过</span>";
				       					    	}else if(row['retrem']==-1){
				       					    		return "<span  onclick=''style='color:red;'>未通过</span>";
				       					    	}
				       					   	}   
				       			       }
				       			       ]]
				       				  });
		       				}
		       			}
		       		}) 
				   
			   
		 }
		 
	 }); 

});
</script>

			<div id=peixunall class="easyui-tabs" style="width:100%;height:540px;border:none;">
		    <div title="培训记录" style="overflow:auto;padding:20px;display:none;border:none;">
		    	<div id="Trainingbox"style="margin-bottom:10px;"> 
		    		姓名：<input id="ss" class="easyui-searchbox" style="width:300px"></input>
				</div>
				<table id="jilu_all" class="easyui-datagrid" style="width:100%;height:345px;"
			    	data-options="fitColumns:true">
				</table>
		    </div>
		    <div title="培训结果" style="overflow:auto;padding:20px;display:none;border:none;">
		   		<div id="Trainingbox1" style="margin-bottom:10px;"> 
					姓名：<input id="yy_" class="easyui-searchbox" style="width:300px"></input>
				</div>
				<table id="TrainingResulttable" class="easyui-datagrid" style="width:100%;height:345px;" data-options="fitColumns:true">	
				</table>
		    </div>
	</div>
</body>
</html>